<template>
    <div class="welcome-container">
      <!-- 顶部导航 -->
      <div class="header">
        <div class="logo">
          <img src="@/assets/treval/wallhaven1.png" alt="景区logo">
          <span>云南</span>
        </div>
        <el-menu 
          mode="horizontal"
          text-color="#fff"
          active-text-color="#ffd04b">
          <el-menu-item index="1" @click="navigateToHome" class="is-active">首页</el-menu-item>
          <el-menu-item index="2" @click="navigateToIntro">景区介绍</el-menu-item>
          <el-menu-item index="3" @click="navigateToCommend">推荐</el-menu-item>
          <el-menu-item index="4" @click="navigateToSearch">搜索</el-menu-item>
          <el-menu-item index="5">个人中心</el-menu-item>
        </el-menu>
      </div>
  
      <!-- 轮播图 -->
      <el-carousel height="100vh" :interval="5000" arrow="always" style="width: 100%">
        <el-carousel-item 
          v-for="item in 3" 
          :key="item"
          style="display: flex; justify-content: center; align-items: center"
        >
          <div 
            class="carousel-item"
            :style="{
              backgroundImage: `url(${require(`@/assets/banner${item}.jpg`)})`,
              width: '100%'
            }"
          >
            <div class="carousel-text" v-if="item === 1">
              <h2><strong>四季如春的独特魅力</strong></h2>
              <p>感受多民族文化的独特魅力</p>
              <p>探索云南的多彩气候与壮丽地貌</p>
            </div>
            <div class="carousel-text" v-if="item === 2">
              <h2><strong>个性化的景区推荐</strong></h2>
              <p>挑选最心仪的景区</p>
              <p>发现更多云南的自然奇观和人文景观</p>
            </div>
            <div class="carousel-text" v-if="item === 3">
              <h2><strong>未来三日的人数预测</strong></h2>
              <p>提前规划旅游计划和路线</p>
              <p>合理安排行程避免拥挤</p>
            </div>
          </div>
        </el-carousel-item>
      </el-carousel>
      
  
      <!-- 新增图片容器 -->
      <div class="custom-image-container">
        <div class="image-overlay">
          <div class="stats">
              <!-- 左侧统计模块 -->
              <div class="stat-group">
                  <div class="stat-item" v-for="stat in stats.slice(0,4)" :key="stat.label1">
                      <count-up
                          class="stat-number"
                          :endVal="stat.value"
                          :options="statOptions"
                      ></count-up>
                      <div class="stat-label">{{ stat.label1 }}</div>
                  </div>
              </div>
  
              <!-- 中间统计模块 -->
              <div class="stat-group">
                  <div class="stat-item" v-for="stat in stats.slice(4)" :key="stat.label2">
                      <count-up
                          class="stat-number"
                          :endVal="stat.value"
                          :options="statOptions"
                      ></count-up>
                      <div class="stat-label">{{ stat.label2 }}</div>
                  </div>
              </div>
  
              <!-- 右侧按钮 -->
              <div class="overlay-button">
                  <el-button 
                  type="primary" 
                  size="large"
                  @click="handleExplore">
                  立即登录 <i class="el-icon-arrow-right"></i>
                  </el-button>
              </div>
          </div>
        </div> <!-- 添加image-overlay闭合标签 -->
        
        <img 
          :src="require('@/assets/treval/wallhaven2.png')" 
          alt="特色景观"
          class="responsive-image"
        >
      </div> <!-- 添加custom-image-container闭合标签 -->
    </div> <!-- 确保welcome-container闭合 -->
  </template>

<script>

// 修改导入语句
import VueCountUp from 'vue-countup-v2'

export default {
  components: {
    CountUp: VueCountUp // 使用兼容Vue2的版本
  },
  data() {
    return {
      statOptions: {
        duration: 2.5,
        useEasing: true,
        separator: ','
      },
      stats: [
        { label1: '景区面积(平方公里)', value: 1542 },
        { label1: '动植物种类', value: 4236 },
        { label1: '年接待游客', value: 1850000 },
        { label1: '遗产保护数量', value: 23 },
        // 新增四个统计项 ▼
        { label2: '文化遗址数量', value: 86 },
        { label2: '特色服务项目', value: 152 },
        { label2: '游客好评率', value: 98.7 },
        { label2: '公共设施数量', value: 3654 }
      ],
    }
  },
  methods: {
    setPageTitle() {
      document.title = '景区介绍'; // 动态设置页面标题
    },
    navigateToHome() {
      this.$router.push('/treval/welcome');
    },
    navigateToIntro() {
        this.$router.push('/treval/intro');
    },
    navigateToCommend() {
        this.$router.push('/treval/commend');
    },
    navigateToSearch() {
        this.$router.push('/treval/search');
    },
  }
}
</script>

<style scoped>
.welcome-container {
  background-color: #e3ded0;
  overflow-x: hidden; /* 防止横向滚动 */
  
  /* 新增全局宽度约束 */
  * {
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* 通用图片约束 */
.welcome-container img {
  max-width: 100%;
  height: auto;
  display: block; /* 消除图片底部间隙 */
}


.header {
  display: flex;
  justify-content: space-between;
  padding: 0 50px;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 9999; /* 提升层级确保覆盖所有元素 */
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1); /* 添加阴影增强层次感 */
  position: fixed;
  top: 0;
  backdrop-filter: blur(5px); /* 毛玻璃效果 */
  font-weight: bold;
}

/* 优化菜单项样式 */
.el-menu {
  background: transparent !important; /* 透明背景 */
}

.el-menu-item {
  font-size: 18px !important;  /* 加大字体 */
  font-weight: 600 !important; /* 加粗字体 */
  padding: 0 20px !important; /* 增加间距 */
  transition: all 0.3s !important;
}

.el-menu-item:hover {
  background-color: rgba(255, 255, 255, 0.1) !important; /* 悬停效果 */
  border-bottom: 2px solid #ffd04b !important; /* 下划线指示 */
}

.el-menu-item.is-active {
  color: #ffd04b !important;
  border-bottom: 2px solid #ffd04b !important;
  background-color: rgba(173, 216, 230, 0.3) !important; /* 淡蓝色半透明背景 */
  backdrop-filter: blur(8px) !important; /* 磨砂玻璃效果 */
  -webkit-backdrop-filter: blur(8px) !important; /* 兼容Safari */
  transition: all 0.3s !important; /* 添加过渡动画 */
}

.el-menu-item:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
  border-bottom: 2px solid #ffd04b !important;
  backdrop-filter: blur(4px) !important; /* 悬停时添加轻度模糊 */
  -webkit-backdrop-filter: blur(4px) !important;
}

.logo {
  display: flex;
  align-items: center;
  color: #fff;
  font-size: 24px;
  img {
    height: 40px;
    margin-right: 15px;
  }
}

/* 修改轮播图容器样式 */
.el-carousel {
  margin-top: 0; /* 移除顶部间距 */
  padding: 0 5px;
  border-radius: 4px;
}

.carousel-item {
      width: 100% !important;
      height: 100vh; /* 基础可视高度 */
      min-height: 400px; /* 最小保证显示区域 */
      background-size: cover;
      background-position: center;
      background-repeat: no-repeat;
      margin: 0 auto;
}

.carousel-text {
  color: #e1e6dd;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: 90%;
  font-size: 4vh;
  font-weight: bold;
}


.feature-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 30px;
  padding: 50px 10%;
}

.feature-card {
  transition: transform 0.3s;
  text-align: center;
  &:hover {
    transform: translateY(-10px);
  }
  .card-icon {
    width: 80px;
    height: 80px;
    margin: 20px auto;
  }
}

.route-card:hover .route-image {
  transform: scale(1.03);
}

/* 新增图片容器样式 */
.custom-image-container {
  width: 100vw;
  margin: 10px 0;
  padding: 0 5px;
  position: relative;
}

.responsive-image {
  width: 100%;
  height: auto;
  max-width: 1200px;
  margin: 0 auto;
  display: block;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* 调整叠加层定位 */
.image-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 85%;
  height: 80%;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 统计模块和按钮三等分 */
.stats {
    color: white;
    padding: 4vh 0; /* 减少垂直间距 */
    display: flex;
    justify-content: space-between; /* 三列等宽分布 */
    flex-direction: row;
    width: 100%;
    box-sizing: border-box;
}

.stat-group {
    flex: 1;  /* 自动分配剩余空间 */
    max-width: 30%; /* 控制最大宽度 */
    display: flex;
    flex-direction: column;
    gap: 4vh;
    align-items: center; /* 垂直居中对齐 */
    justify-content: center; /* 垂直居中对齐 */
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80%; /* 控制项目宽度 */
    padding: 2vh 0; /* 增加垂直内边距 */
}

.stat-number {
    font-size: 5vh; /* 适当缩小字号 */
    font-weight: bold;
    color: #ffd04b;
    margin-bottom: 1.5vh; /* 增加间距 */
    line-height: 1;
}

.stat-label {
    font-size: 2vh; /* 调整标签字号 */
    text-align: center;
    width: 100%; /* 占满容器宽度 */
    font-weight: bold;
    letter-spacing: 0.1vh; /* 增加字间距 */
}

.overlay-button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: static; /* 移除绝对定位 */
    transform: none;
}

.overlay-button .el-button {
    background: rgba(255, 255, 255, 0.2) !important; /* 半透明背景 */
    border-color: transparent !important; /* 透明边框 */
    padding: 1.5vh 3vh; /* 使用vh单位 */
    font-size: 3vh; /* 基于视口高度 */
    border-radius: 3vh;
    transition: all 0.3s;
    
    &:hover {
      background: rgba(255, 255, 255, 0.4) !important;
      transform: scale(1.05); /* 悬停放大效果 */
    }
    
    &:active {
      transform: scale(0.95);
    }

    i {
      margin-left: 1vh;
      font-size: 0.8em;
    }
    
    &:hover i {
      transform: translateX(4px);
    }
}
</style>